package cn.shengchao.examstar.me.collect.acl.adapters.repositories;

import cn.shengchao.examstar.me.collect.acl.ports.repositories.IUserCollectInfoRepository;
import cn.shengchao.examstar.me.infrastructure.dao.UserCollectInfoDao;
import cn.shengchao.examstar.me.infrastructure.dao.po.UserCollectInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: examstarapi
 * @description: 用户信息采集业务实现
 * @author: Xiong weiqiang
 * @create: 2025-04-14 11:52
 */
@Repository
public class UserCollectInfoRepository extends ServiceImpl<UserCollectInfoDao,UserCollectInfo> implements IUserCollectInfoRepository {

    @Autowired
    private UserCollectInfoDao userCollectInfoDao;

    @Override
    public UserCollectInfo getUserCollectInfo(Long userId) {
        return userCollectInfoDao.selectById(userId);
    }

    @Override
    public void saveUserCollectInfo(UserCollectInfo userCollectInfo) {
        if (getUserCollectInfo(userCollectInfo.getUserId())!=null){
            userCollectInfoDao.updateById(userCollectInfo);
        }else {
            userCollectInfoDao.insert(userCollectInfo);
        }
    }

    @Override
    public List<Long> selectNotCollectUserIdList() {
        return userCollectInfoDao.selectNotCollectUserIdList();
    }

    @Override
    public List<Long> selectExistUserIdListByUpdateAsc(int limit) {
        return userCollectInfoDao.selectExistUserIdListByUpdateAsc(limit);
    }
}